<%@page language="java" contentType="text/html; charset=UTF-8"
	import="java.util.Enumeration,
		java.text.DecimalFormat"
%><%!
	private static DecimalFormat mbFormat = new DecimalFormat("#0.00 Mbytes");
%><html>
<head>
<style type="text/css" media="all">
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,form,fieldset,p,blockquote { margin:0;padding:0; }
img { border: 0; }
body {
	font-size:12px; font-family:arial;
}
#dataContent {

}
#dataContent table {
	width: 100%;
	border:1px solid #e3dbd9;
}
#dataContent caption {
	font-size:18px;
}
#dataContent thead {
	text-align:left;
}
#dataContent tr {
	padding:0 7px 0 7px;
}
#dataContent th td {
	padding:0 7px 0 7px;
	text-align: left;
}
th.name {
	width:200px;
}
th.value {
	width:500px;
}
</style>
<title>Java Info</title>
</head>

<body>

<h1>Java Info</h1>
<div id="dataContent">
<%
	ServletContext servletCtx = getServletConfig().getServletContext();
	JspFactory jspFactory = JspFactory.getDefaultFactory();
%>
	<table>
	<caption>Java Server</caption>
	<thead>
	<tr>
		<th class="name">Name</th>
		<th>Value</th>
	</tr>
	</thead>
	<tbody>
	<tr>
		<td><b>Server Info</b></td>
		<td><%= servletCtx.getServerInfo() %></td>
	</tr>
	<tr>
		<td><b>Servlet Spec.</b></td>
		<td><%= servletCtx.getMajorVersion() %>.<%= servletCtx.getMinorVersion() %></td>
	</tr>
	<tr>
		<td><b>JSP Spec.</b></td>
		<td><%= jspFactory.getEngineInfo().getSpecificationVersion() %></td>
	</tr>
	</tbody>
	</table>
<%
	Runtime runtime = Runtime.getRuntime();
	String maxMemory   = mbFormat.format((double)runtime.maxMemory() / (1024 * 1024) );
	String totalMemory = mbFormat.format((double)runtime.totalMemory() / ( 1024 * 1024) );
	String freeMemory  = mbFormat.format((double)runtime.freeMemory() / ( 1024 * 1024) );
%>

	<table>
	<caption>Memory Information</caption>
	<thead>
	<tr>
		<th class="name">Name</th>
		<th>Value</th>
	</tr>
	</thead>
	<tbody>
	<tr>
		<td><b>Max Memory</b></td>
		<td><%= maxMemory %></td>
	</tr>
	<tr>
		<td><b>Total Memory</b></td>
		<td><%= totalMemory %></td>
	</tr>
	<tr>
		<td><b>Free Memory</b></td>
		<td><%= freeMemory %></td>
	</tr>
	</tbody>
	</table>

	<table>
	<caption>Java Server Properties</caption>
	<thead>
	<tr>
		<th class="name">Name</th>
		<th>Value</th>
	</tr>
	</thead>
	<tbody>
<%
	Enumeration e = System.getProperties().propertyNames();
	String pathSep = System.getProperty("path.separator");
	while(e.hasMoreElements()) {
		String key = (String)e.nextElement();
%>
	<tr>
		<td><b><%= key %></b></td>
		<td><%= (!key.endsWith(".path")) ? System.getProperty(key) : System.getProperty(key).replace(pathSep, "<br/>") %></td>
	</tr>
<%
	}
%>
	</tbody>
	</table>
</div>
</body>
</html>
